home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gsbittab.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  3.1 KB  |  85 lines

  1. /* Copyright (C) 1995, 1996, 1997, 1998 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gsbittab.h,v 1.2 2000/09/19 19:00:25 lpd Exp $ */
  20. /* Interface to tables for bit operations */
  21.  
  22. #ifndef gsbittab_INCLUDED
  23. #  define gsbittab_INCLUDED
  24.  
  25. /*
  26.  * Generate tables for transforming 2, 4, 6, or 8 bits.
  27.  */
  28. #define btab2_(v0,v2,v1)\
  29.   v0,v1+v0,v2+v0,v2+v1+v0
  30. #define bit_table_2(v0,v2,v1) btab2_(v0,v2,v1)
  31. #define btab4_(v0,v8,v4,v2,v1)\
  32.   btab2_(v0,v2,v1), btab2_(v4+v0,v2,v1),\
  33.   btab2_(v8+v0,v2,v1), btab2_(v8+v4+v0,v2,v1)
  34. #define bit_table_4(v0,v8,v4,v2,v1) btab4_(v0,v8,v4,v2,v1)
  35. #define btab6_(v0,v20,v10,v8,v4,v2,v1)\
  36.   btab4_(v0,v8,v4,v2,v1), btab4_(v10+v0,v8,v4,v2,v1),\
  37.   btab4_(v20+v0,v8,v4,v2,v1), btab4_(v20+v10+v0,v8,v4,v2,v1)
  38. #define bit_table_6(v0,v20,v10,v8,v4,v2,v1) btab6_(v0,v20,v10,v8,v4,v2,v1)
  39. #define bit_table_8(v0,v80,v40,v20,v10,v8,v4,v2,v1)\
  40.   btab6_(v0,v20,v10,v8,v4,v2,v1), btab6_(v40+v0,v20,v10,v8,v4,v2,v1),\
  41.   btab6_(v80+v0,v20,v10,v8,v4,v2,v1), btab6_(v80+v40+v0,v20,v10,v8,v4,v2,v1)
  42.  
  43. /*
  44.  * byte_reverse_bits[B] = the byte B with the order of bits reversed.
  45.  */
  46. extern const byte byte_reverse_bits[256];
  47.  
  48. /*
  49.  * byte_right_mask[N] = a byte with N trailing 1s, 0 <= N <= 8.
  50.  */
  51. extern const byte byte_right_mask[9];
  52.  
  53. /*
  54.  * byte_count_bits[B] = the number of 1-bits in a byte with value B.
  55.  */
  56. extern const byte byte_count_bits[256];
  57.  
  58. /*
  59.  * byte_bit_run_length_N[B], for 0 <= N <= 7, gives the length of the
  60.  * run of 1-bits starting at bit N in a byte with value B,
  61.  * numbering the bits in the byte as 01234567.  If the run includes
  62.  * the low-order bit (i.e., might be continued into a following byte),
  63.  * the run length is increased by 8.
  64.  */
  65. extern const byte
  66.     byte_bit_run_length_0[256], byte_bit_run_length_1[256],
  67.     byte_bit_run_length_2[256], byte_bit_run_length_3[256],
  68.     byte_bit_run_length_4[256], byte_bit_run_length_5[256],
  69.     byte_bit_run_length_6[256], byte_bit_run_length_7[256];
  70.  
  71. /*
  72.  * byte_bit_run_length[N] points to byte_bit_run_length_N.
  73.  * byte_bit_run_length_neg[N] = byte_bit_run_length[-N & 7].
  74.  */
  75. extern const byte *const byte_bit_run_length[8];
  76. extern const byte *const byte_bit_run_length_neg[8];
  77.  
  78. /*
  79.  * byte_acegbdfh_to_abcdefgh[acegbdfh] = abcdefgh, where the letters
  80.  * denote the individual bits of the byte.
  81.  */
  82. extern const byte byte_acegbdfh_to_abcdefgh[256];
  83.  
  84. #endif /* gsbittab_INCLUDED */
  85.